//
//  AboutVC.m
//  jzyStudents
//
//  Created by 任辰东 on 2022/9/22.
//

#import "AboutVC.h"
#import "RCDTextFeidView.h"
#import "UILabel+LineSpace.h"

@interface AboutVC ()
@property (nonatomic, strong) UIView *topView;
@property (nonatomic, strong) UIImageView *logoImageView;
@property (nonatomic, strong) UILabel *infoLabel;
@property (nonatomic, strong) RCDTextFeidView *versonView;
@property (nonatomic, strong) RCDTextFeidView *mobileView;
@property (nonatomic, strong) UIControl *mobileBg;
@end

@implementation AboutVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"关于";
    
}

- (void)mobileViewAction
{
    
    NSMutableString * str = [[NSMutableString alloc] initWithFormat:@"tel:%@",@"0391-5288106"];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str] options:@{} completionHandler:nil];
}

-(void)setupViews
{
    [self.bgScrollView.contentView addSubview:self.topView];
    [self.topView addSubview:self.logoImageView];
    [self.topView addSubview:self.infoLabel];
    [self.bgScrollView.contentView addSubview:self.versonView];
    [self.bgScrollView.contentView addSubview:self.mobileView];
    [self.bgScrollView.contentView addSubview:self.mobileBg];
    [self.mobileBg addTarget:self action:@selector(mobileViewAction) forControlEvents:UIControlEventTouchUpInside];
    
    [self.mobileView setTouchDownTarget:self action:@selector(mobileViewAction)];
}

-(void)setupLayout
{
    [self.topView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.left.right.equalTo(self.bgScrollView.contentView);
        make.top.equalTo(self.bgScrollView.contentView).offset(0);
    }];
    
    [self.logoImageView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.topView).offset(50);
        make.centerX.equalTo(self.topView);
        make.height.mas_equalTo(80);
        make.width.mas_equalTo(80);
    }];
//    self.logoImageView.layer.cornerRadius = 50;
//    self.logoImageView.layer.masksToBounds = YES;
    
    
    [self.infoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.logoImageView.mas_bottom).offset(50);
        make.left.equalTo(self.topView).offset(15);
        make.right.equalTo(self.topView).offset(-15);
        make.bottom.equalTo(self.topView).offset(-15);
    }];
    
    [self.versonView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.topView.mas_bottom).offset(15);
        make.left.equalTo(self.bgScrollView.contentView).offset(-6);
        make.right.equalTo(self.bgScrollView.contentView).offset(0);
        make.height.mas_equalTo(50);
    }];
    
    [self.mobileView mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.versonView.mas_bottom).offset(0);
        make.left.equalTo(self.bgScrollView.contentView).offset(-6);
        make.right.equalTo(self.bgScrollView.contentView).offset(0);
        make.height.mas_equalTo(50);
        make.bottom.equalTo(self.bgScrollView.contentView).offset(kBottomOffset);
    }];
    
    [self.mobileBg mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.top.equalTo(self.versonView.mas_bottom).offset(0);
        make.left.equalTo(self.bgScrollView.contentView).offset(-6);
        make.right.equalTo(self.bgScrollView.contentView).offset(0);
        make.height.mas_equalTo(50);
        make.bottom.equalTo(self.bgScrollView.contentView).offset(kBottomOffset);
    }];
}


#pragma mark -- lazylod

-(UIView *)topView
{
    if (!_topView) {
        _topView = [UIView new];
        _topView.backgroundColor = UIColorFromHex(kColorWhite);
    }
    return _topView;
}

-(UIImageView *)logoImageView
{
    if (!_logoImageView) {
        
        _logoImageView = [UIImageView new];
        _logoImageView.image = UIImageWithName(@"mine_logo");
        _logoImageView.contentMode = UIViewContentModeScaleAspectFill;
        _logoImageView.clipsToBounds = YES;
    }
    return _logoImageView;
}

-(UILabel *)infoLabel
{
    if (!_infoLabel) {
        _infoLabel = [UILabel new];
//        _infoLabel.text = @"教之源错题本是怀府网旗下开发的APP，本产品主要针对于学校内部制度的管理，达到快速解决学校繁杂功能的效果，欢迎广大用户使用。";
        _infoLabel.font = UIFontSize(15);
        _infoLabel.textColor = UIColorFromHex(0x333333);
        _infoLabel.numberOfLines = 0;
        [_infoLabel setText:@" 教之源学生为广大中小学生提供教育资源专属化服务。学生可查看教师发布学习内容进行学习，也可自动记录联考、考试、测验等过程中产生的错题，将错题快速整理成册。为更方便的让孩子掌握知识和查找薄弱知识点，我们开发了教之源学生。减轻教师和家长的工作负担，也减轻了孩子的负担，提高学习效率。" lineSpacing:7];
        _infoLabel.textAlignment = NSTextAlignmentJustified;
    }
    return _infoLabel;
}

-(RCDTextFeidView *)versonView
{
    if (!_versonView) {
        RCDTextFeidViewModel *model = [RCDTextFeidViewModel new];
        model.leftTitle = @"当前版本";
        model.leftTitleFont = UIFontSize(15);
        model.leftTitleColor = UIColorFromHex(kColorTitle);
        model.isNotEnable = YES;
        model.alignment = NSTextAlignmentRight;
        model.content = [NSString stringWithFormat:@"V%@",kCurrentBundleVersion];
        model.contentColor = UIColorFromHex(0x000000);
        model.contentFont = UIFontSize(15);
        _versonView = [[RCDTextFeidView alloc]initWithModel:model];
        _versonView.backgroundColor = UIColorFromHex(kColorWhite);
        [_versonView addBottomLineWithEdge:UIEdgeInsetsMake(0, 15, 0, 15)];
    }
    return _versonView;
}

-(RCDTextFeidView *)mobileView
{
    if (!_mobileView) {
        RCDTextFeidViewModel *model = [RCDTextFeidViewModel new];
        model.leftTitle = @"客服电话";
        model.leftTitleFont = UIFontSize(15);
        model.leftTitleColor = UIColorFromHex(kColorTitle);
        model.alignment = NSTextAlignmentRight;
//        model.content = [NSString stringWithFormat:@"V%@",kCurrentBundleVersion];
        model.content = @"0391-5288106";
        model.contentColor = UIColorFromHex(0x000000);
        model.contentFont = UIFontSize(15);
        model.rightImgPath = @" ";
        model.isNotEnable = YES;
        _mobileView = [[RCDTextFeidView alloc]initWithModel:model];
        _mobileView.backgroundColor = UIColorFromHex(kColorWhite);
        [_mobileView addBottomLine];
    }
    return _mobileView;
}

-(UIControl *)mobileBg
{
    if (!_mobileBg) {
        _mobileBg = [UIControl new];
        _mobileBg.backgroundColor = [UIColor clearColor];
    }
    return _mobileBg;
}


@end
